package com.jiyici.network;

import org.json.JSONObject;

import jiyici.Server2ClientSyncData;

import com.jiyici.model.Category;
import com.jiyici.model.Item;

public class FakeWebClient implements IWebCient {

    @Override
    public Result register(String email, String userName, String password) {
        __sleep();
        String response = "{'action':1,'result':0,'data':{'id':1,'email':'jy@jy.com','userName':'Jerry','token':'5a1f50f7-8635-4e7b-86e8-1f982a73352e'}}";
        return Result.parseResponse(response);
    }

    @Override
    public Result login(String email, String password) {
        __sleep();
        String response = "{'action':2,'result':0,'data':{'id':1,'email':'jy@jy.com','userName':'Jerry','token':'5a1f50f7-8635-4e7b-86e8-1f982a73352e'}}";
        return Result.parseResponse(response);
    }

    @Override
    public Result syncServer2Client(Server2ClientSyncData syncData) {
        // TODO Auto-generated method stub
        return null;
    }

//    @Override
//    public Result saveItem(Item item) {
//        __sleep();
//        String response = "{'action':3,'result':0,'data':{'id':1,'itemName':'snooker','category':'sport','displayIndex':0,'recordCount':0,'params':[{'id':1,'itemParamName':'DaMo','type':1,'isMust':true}]}}";
//        return Result.parseResponse(response);
//    }
//
//    @Override
//    public Result getCategoryList() {
//        __sleep();
//        String response = "{'action':2003,'result':0,'data':{'categories':[{'id':2,'name':'sportxxx','displayOrder':'bb'},{'id':3,'name':'work','displayOrder':'bb'}]}}";
//        return Result.parseResponse(response);
//    }
//
//    @Override
//    public Result getItemListFor(Category category) {
//        // TODO Auto-generated method stub
//        return null;
//    }
//
//    @Override
//    public Result getItem() {
//        __sleep();
//        String response = "{'action':2001,'result':0,'data':{'items': [{'id':1,'itemName':'snooker','category':2,'displayIndex':0,'recordCount':0,'params':[{'id':1,'itemParamName':'DaMo','type':1,'isMust':true}]},{'id':2,'itemName':'吵架','category':0,'displayIndex':0,'recordCount':0,'params':[{'id':1,'itemParamName':'caused by','type':1,'isMust':true},{'id':1,'itemParamName':'days','type':2,'isMust':false}]}, {'id':3,'itemName':'跑步','category':3,'displayIndex':0,'recordCount':0,'params':[{'id':1,'itemParamName':'distance','type':2,'isMust':true}]}]}}";
//        return Result.parseResponse(response);
//    }

    @Override
    public Result syncClient2Server(JSONObject data) {
        // TODO Auto-generated method stub
        return null;
    }

    private void __sleep() {
        try {
            Thread.sleep(800);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
